char A; //input in char
int led1=9;   //set led1=pin9
int led2=10;  //set led2=pin10

void setup(){
  
  Serial.begin(9600);  //begin
  pinMode(led1,OUTPUT);   //set up pin9 of arduino as the output
  pinMode(led2,OUTPUT);  //set up pin10 of arduino as the output
  pinMode(11,INPUT);   //set up pin11 of arduino as the input

}

void loop(){
 
  if (Serial.available() > 0) {
    
    if(digitalRead(11)==HIGH){
    
      A=Serial.read(); // read input from Serial Monitor
  
  switch(A){
    case 'L':// if the input is L (Lock door)
      digitalWrite(led1, HIGH); //LED D9 turn on
      digitalWrite(led2, HIGH); //LED D10 (notification) blink for 1 sec
      delay(1000);
      digitalWrite(led2, LOW);
      break;
      
    case 'U': //if the input is U (Unlock door)
      digitalWrite(led1, LOW); //LED D9 turn off
      digitalWrite(led2, HIGH); //LED D10 (notification) blink for 1 sec twice
      delay(1000);
      digitalWrite(led2, LOW);
      delay(1000);
      digitalWrite(led2, HIGH);
      delay(1000);
      digitalWrite(led2, LOW);
      break;
  }
    }

    else {
    digitalWrite(led1, LOW);
    digitalWrite(led2, LOW);
      
    }

  }
}



